package 代码随想录.字符串.替换空格;

/**lc:剑指 Offer 05. 替换空格
 * link:https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/
 * @author ChenweiLin
 * @create 2021-12-22 10:33
 */
public class TiHuanKongGeicof {
    public static void main(String[] args) {

    }

    class Solution {
        public String replaceSpace(String s) {
            char[] sChar = s.toCharArray();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == ' '){
                    sb.append("%20");
                }else{
                    sb.append(s.charAt(i));
                }
            }

            return sb.toString();
        }
    }
}
